package com.zch.work.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zch.domain.Result;
import com.zch.entity.TbProcess;
import com.zch.work.service.TbProcessService;
import com.zch.work.mapper.TbProcessMapper;
import com.zch.work.vo.DeletedVo;
import com.zch.work.vo.ProcessVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 28763
* @description 针对表【tb_process(工序维护)】的数据库操作Service实现
* @createDate 2023-10-30 19:57:14
*/
@Service
public class TbProcessServiceImpl extends ServiceImpl<TbProcessMapper, TbProcess>
    implements TbProcessService{

    @Autowired
    TbProcessMapper tbProcessMapper;


    @Override
    public Result selectAll(ProcessVo processVo) {
        //逻辑删除字段为1 name符合条件 分页查询 一页十个数据
            Page<TbProcess> page = new Page<>(processVo.getPageNum(), processVo.getPageSize());
            Page<TbProcess> list = tbProcessMapper.selectAll(page,processVo.getName());
            return Result.SUCCESS(list);
    }

    @Override
    public Result deleted(DeletedVo deletedVo) {
        TbProcess tbProcess = new TbProcess();
        tbProcess.setId(deletedVo.getId());
        tbProcess.setDeleted(1);
        boolean b = updateById(tbProcess);
        if (b){
            return Result.SUCCESS();
        }else {
            return Result.FAILED(201,"删除成功");
        }
    }

    @Override
    public Result updateByID(TbProcess tbProcess) {
        boolean b = updateById(tbProcess);
        return b?Result.SUCCESS():Result.FAILED(201,"修改失败");
    }

    @Override
    public Result addProcess(TbProcess tbProcess) {
        boolean save = save(tbProcess);
        return save?Result.SUCCESS():Result.FAILED(201,"修改失败");
    }
}




